#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL n,l,r;
LL p;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld%lld%lld",&n,&l,&r);
	p=r/n;
	if(p*n-1<l){
		printf("%lld",r-p*n);
		return 0;
	}
	printf("%lld",max(r-p*n,n-1));
	return 0;
}


